#include <iostream>
using namespace std;
#include <deque>
#include <algorithm>

//vector是单端数组 只能在尾部弹入弹出push_back() pop_back()
//deque是双端数组 可以在头部和尾部弹入弹出push_back() pop_back() push_front() pop_front()
//deque和vector非常类似

void printD(deque<int> &d)
{
        for (deque<int>::iterator it = d.begin(); it != d.end(); it++)
        {
                cout<<*it<<" ";
        }
        cout<<endl;
}

void test1()
{
        deque<int> d1;
        d1.push_back(1);
        d1.push_back(2);
        d1.push_back(3);

        d1.push_front(-11);
        d1.push_front(-33);
        d1.push_front(-55);

        cout<<"头部元素: "<<d1.front()<<endl;
        cout<<"尾部元素: "<<d1.back()<<endl;
        printD(d1);

        d1.pop_front();
        d1.pop_back();
        printD(d1);

        //查找 -33 在数组下标的值
        deque<int>::iterator it = find(d1.begin(), d1.end(), -33);
        if(it != d1.end()){
                cout<<"-33在数组下标是 "<<distance(d1.begin(), it)<<endl;
        }else{
                cout<<"没有找到值为-33的值"<<endl;
        }
}

int main(int argc, char const *argv[])
{
        test1();        
        return 0;
}
